<?php

  session_start();
  include "config.php";
  include "ALcustomer.php";

  if(isset($_SESSION["user"]))
  {
    include "$header";
    include "$body";

?>

<div style="position:absolute; top:0px; left:1px; border:0;">
  <span class="prevPage">Record New Customer Details:Search > </span>
  <span class="prevPage">Record Details > </span>
  <span class="page">Confirm Details</span>
</div>

<?php

    include "$H_rncd";

    $title = ltrim($_SESSION["cr_title"]);
    switch ($title)
    {
      case "0": $titlen = "Miss"; break;
      case "1": $titlen = "Mr"; break;
      case "2": $titlen = "Mrs"; break;
      case "3": $titlen = "Ms"; break;
    }
    $surname = ltrim($_SESSION["cr_surname"]);
    $given_name = ltrim($_SESSION["cr_given_name"]);
    $dob_day = ltrim($_SESSION["cr_dob_day"]);
    $dob_month = ltrim($_SESSION["cr_dob_month"]);
    switch ($dob_month)
    {
      case "01": $dob_monthn = "January"; break;
      case "02": $dob_monthn = "February"; break;
      case "03": $dob_monthn = "March"; break;
      case "04": $dob_monthn = "April"; break;
      case "05": $dob_monthn = "May"; break;
      case "06": $dob_monthn = "June"; break;
      case "07": $dob_monthn = "July"; break;
      case "08": $dob_monthn = "August"; break;
      case "09": $dob_monthn = "September"; break;
      case "10": $dob_monthn = "October"; break;
      case "11": $dob_monthn = "November"; break;
      case "12": $dob_monthn = "December"; break;
    }
    $dob_year = ltrim($_SESSION["cr_dob_year"]);
    $address = ltrim($_SESSION["cr_address"]);
    $post_code = ltrim($_SESSION["cr_pcode"]);
    $ph_area1 = ltrim($_SESSION["cr_ph_area1"]);
    $ph_no1 = ltrim($_SESSION["cr_ph_no1"]);
    $ph_area2 = ltrim($_SESSION["cr_ph_area2"]);
    $ph_no2 = ltrim($_SESSION["cr_ph_no2"]);
    $card_type1 = ltrim($_SESSION["cr_card_type1"]);
    switch ($card_type1)
    {
      case "0": $card_type1n = "Mastercard"; break;
      case "1": $card_type1n = "Visa"; break;
      case "2": $card_type1n = "Amex"; break;
      case "3": $card_type1n = "Diners Club"; break;
    }
    $card_name1 = ltrim($_SESSION["cr_card_name1"]);
    $card_no1_1 = ltrim($_SESSION["cr_card_no1_1"]);
    $card_no1_2 = ltrim($_SESSION["cr_card_no1_2"]);
    $card_no1_3 = ltrim($_SESSION["cr_card_no1_3"]);
    $card_no1_4 = ltrim($_SESSION["cr_card_no1_4"]);
    $card_expiry_month1 = ltrim($_SESSION["cr_card_expiry_month1"]);
    switch ($card_expiry_month1)
    {
      case "01": $card_expiry_month1n = "January"; break;
      case "02": $card_expiry_month1n = "February"; break;
      case "03": $card_expiry_month1n = "March"; break;
      case "04": $card_expiry_month1n = "April"; break;
      case "05": $card_expiry_month1n = "May"; break;
      case "06": $card_expiry_month1n = "June"; break;
      case "07": $card_expiry_month1n = "July"; break;
      case "08": $card_expiry_month1n = "August"; break;
      case "09": $card_expiry_month1n = "September"; break;
      case "10": $card_expiry_month1n = "October"; break;
      case "11": $card_expiry_month1n = "November"; break;
      case "12": $card_expiry_month1n = "December"; break;
    }
    $card_expiry_year1 = ltrim($_SESSION["cr_card_expiry_year1"]);
    $card_type2 = ltrim($_SESSION["cr_card_type2"]);
    switch ($card_type2)
    {
      case "Select:": $card_type2n = ""; break;
      case "0": $card_type2n = "Mastercard"; break;
      case "1": $card_type2n = "Visa"; break;
      case "2": $card_type2n = "Amex"; break;
      case "3": $card_type2n = "Diners Club"; break;
    }

    if($card_type2n == "" || ltrim($_SESSION["cr_card_name2"]) == "" || ltrim($_SESSION["cr_card_no2_1"]) == "" || ltrim($_SESSION["cr_card_no2_2"]) == "" || ltrim($_SESSION["cr_card_no2_3"]) == "" || ltrim($_SESSION["cr_card_no2_4"]) == "")
    {
      $card_type2n = "";
      $card_name2 = "";
      $card_no2_1 = "";
      $card_no2_2 = "";
      $card_no2_3 = "";
      $card_no2_4 = "";
      $card_expiry_month2n = "";
      $card_expiry_year2 = "";
    }
    else
    {
      $card_name2 = ltrim($_SESSION["cr_card_name2"]);
      $card_no2_1 = ltrim($_SESSION["cr_card_no2_1"]);
      $card_no2_2 = ltrim($_SESSION["cr_card_no2_2"]);
      $card_no2_3 = ltrim($_SESSION["cr_card_no2_3"]);
      $card_no2_4 = ltrim($_SESSION["cr_card_no2_4"]);
      $card_expiry_month2 = ltrim($_SESSION["cr_card_expiry_month2"]);
      switch ($card_expiry_month2)
      {
        case "01": $card_expiry_month2n = "January"; break;
        case "02": $card_expiry_month2n = "February"; break;
        case "03": $card_expiry_month2n = "March"; break;
        case "04": $card_expiry_month2n = "April"; break;
        case "05": $card_expiry_month2n = "May"; break;
        case "06": $card_expiry_month2n = "June"; break;
        case "07": $card_expiry_month2n = "July"; break;
        case "08": $card_expiry_month2n = "August"; break;
        case "09": $card_expiry_month2n = "September"; break;
        case "10": $card_expiry_month2n = "October"; break;
        case "11": $card_expiry_month2n = "November"; break;
        case "12": $card_expiry_month2n = "December"; break;
      }
      $card_expiry_year2 = ltrim($_SESSION["cr_card_expiry_year2"]);
    }

    if(isset($_GET["yes"]))
    {
      if(insertNewCustomerDetails($title, $surname, $given_name, $dob_day, $dob_month, $dob_year, $address, $post_code, $ph_area1, $ph_no1, $ph_area2, $ph_no2, $card_type1, $card_name1, $card_no1_1, $card_no1_2, $card_no1_3, $card_no1_4, $card_expiry_month1, $card_expiry_year1, $card_type2, $card_name2, $card_no2_1, $card_no2_2, $card_no2_3, $card_no2_4, $card_expiry_month2, $card_expiry_year2) == false)
      {
        echo "<SCRIPT language='Javascript'>";
        echo "  alert('The details could not be added.  Please try again.');";
        echo "</SCRIPT>";
      }
      else
      {
        echo "<SCRIPT language='Javascript'>";
        echo "  window.location.href = 'recordNewCustomerDetails_3success.php';";
        echo "</SCRIPT>";
      }
    }
    else if(isset($_GET["no"]))
    {
      echo "<SCRIPT language='Javascript'>";
      echo "  window.location.href = 'recordNewCustomerDetails_1recordDetails.php';";
      echo "</SCRIPT>";
    }
    else
    {
    }

?>

<b>CONFIRMATION: ARE THESE DETAILS ACCURATE?</b>
<p>
<FORM name="customerForm" action="" method="get">
<TABLE class="customer" cellpadding="5" cellspacing="5">
  <TR>
    <TD class="cField">
      Title<font color="red">*</font>
    </TD>
    <TD class="cDetails">
      <input type="text" class="customerConfirm" name="title" style="width:70px;" value="<?php echo $titlen; ?>" readonly />
    </TD>
  </TR>
  <TR>
    <TD class="cField">
	  Surname<font color="red">*</font>
	</TD>
    <TD class="cDetails">
	  <input type="text" class="customerConfirm" name="surname" style="width:150px;" value="<?php echo $surname; ?>" readonly />
	</TD>
  </TR>
  <TR>
    <TD class="cField">
	  Given Name<font color="red">*</font>
	</TD>
	<TD class="cDetails">
	  <input type="text" class="customerConfirm" name="given_name" style="width:150px" value="<?php echo $given_name; ?>" readonly />
	</TD>
  </TR>
  <TR>
    <TD class="cField">
	  Date of Birth<font color="red">*</font>
	</TD>
	<TD class="cDetails">
      <input type="text" class="customerConfirm" name="dob_day" style="width:40px;" value="<?php echo $dob_day; ?>" readonly />
      <input type="text" class="customerConfirm" name="dob_month" style="width:90px" readonly value="<?php echo $dob_monthn; ?>" />
      <input type="text" class="customerConfirm" name="dob_year" style="width:60px" value="<?php echo $dob_year; ?>" readonly />
	</TD>
  </TR>
  <TR>
    <TD class="cField">
	  Address<font color="red">*</font>
	</TD>
	<TD class="cDetails">
	  <input type="text" class="customerConfirm" name="address" style="width:150px" value="<?php echo $address; ?>" readonly />
	</TD>
  </TR>
  <TR>
    <TD class="cField">
	  Post Code<font color="red">*</font>
	</TD>
	<TD class="cDetails">
	  <input type="text" class="customerConfirm" name="post_code" style="width:150px" value="<?php echo $post_code; ?>" readonly />
	</TD>
  </TR>
  <TR>
    <TD class="cField">
      Phone (H)/(M)<font color="red">*</font>
      <br />(W)
	</TD>
	<TD class="cDetails">
      ( <input type="text" class="customerConfirm" name="ph_area1" style="width:30px;" value="<?php echo $ph_area1; ?>" readonly /> )
      <input type="text" class="customerConfirm" name="ph_no1" style="width:100px;" value="<?php echo $ph_no1; ?>" readonly /><br />
      ( <input type="text" class="customerConfirm" name="ph_area2" style="width:30px;" value="<?php echo $ph_area2; ?>" readonly /> )
      <input type="text" class="customerConfirm" name="ph_no2" style="width:100px;" value="<?php echo $ph_no2; ?>" readonly />
	</TD>
  </TR>
  <TR>
    <TD class="cField" valign="top">
      Preferred Credit Card<font color="red">*</font>
	</TD>
	<TD class="cDetails">
      <TABLE style="border:1px solid #000000">
        <TR>
          <TD>
            Card Type: &nbsp; <input type="text" class="customerConfirm" name="card_type1" style="width:100px;" value="<?php echo $card_type1n; ?>" readonly />
          </TD>
        </TR>
        <TR>
          <TD>
            Card Name: &nbsp; <input type="text" class="customerConfirm" name="card_name1" style="width:150px;" value="<?php echo $card_name1; ?>" readonly />
          </TD>
        </TR>
        <TR>
          <TD>
            Card Number: &nbsp; <input type="text" class="customerConfirm" name="card_no1_1" style="width:40px;" value="<?php echo $card_no1_1; ?>" readonly />
            <input type="text" class="customerConfirm" name="card_no1_2" style="width:40px;" value="<?php echo $card_no1_2; ?>" readonly />
            <input type="text" class="customerConfirm" name="card_no1_3" style="width:40px;" value="<?php echo $card_no1_3; ?>" readonly />
            <input type="text" class="customerConfirm" name="card_no1_4" style="width:40px;" value="<?php echo $card_no1_4; ?>" readonly />
          </TD>
        </TR>
        <TR>
          <TD>
            Expiry Date: &nbsp; <input type="text" class="customerConfirm" name="card_expiry_month1" style="width:100px;" value="<?php echo $card_expiry_month1n; ?>" readonly />
            <input type="text" class="customerConfirm" name="card_expiry_year1" style="width:75px;" value="<?php echo $card_expiry_year1; ?>" readonly />
          </TD>
        </TR>
      </TABLE>
	</TD>
  </TR>
  <TR>
    <TD class="cField" valign="top">
      Alternate Credit Card
	</TD>
	<TD class="cDetails">
      <TABLE style="border:1px solid #000000">
        <TR>
          <TD>
            Card Type: &nbsp; <input type="text" class="customerConfirm" name="card_type2" style="width:100px;" value="<?php echo $card_type2n; ?>" readonly />
          </TD>
        </TR>
        <TR>
          <TD>
            Card Name: &nbsp; <input type="text" class="customerConfirm" name="card_name2" style="width:150px;" value="<?php echo $card_name2; ?>" readonly />
          </TD>
        </TR>
        <TR>
          <TD>
            Card Number: &nbsp; <input type="text" class="customerConfirm" name="card_no2_1" style="width:40px;" value="<?php echo $card_no2_1; ?>" readonly />
            <input type="text" class="customerConfirm" name="card_no2_2" style="width:40px;" value="<?php echo $card_no2_2; ?>" readonly />
            <input type="text" class="customerConfirm" name="card_no2_3" style="width:40px;" value="<?php echo $card_no2_3; ?>" readonly />
            <input type="text" class="customerConfirm" name="card_no2_4" style="width:40px;" value="<?php echo $card_no2_4; ?>" readonly />
          </TD>
        </TR>
        <TR>
          <TD>
            Expiry Date: &nbsp; <input type="text" class="customerConfirm" name="card_expiry_month2" style="width:100px;" value="<?php echo $card_expiry_month2n; ?>" readonly />
            <input type="text" class="customerConfirm" name="card_expiry_year2" style="width:75px;" value="<?php echo $card_expiry_year2; ?>" readonly />
          </TD>
        </TR>
      </TABLE>
	</TD>
  </TR>
</TABLE>
<p>
<input class="submit_off" type="submit" value="No" name="no" onmouseover="className='submit_on'" onmouseout="className='submit_off'" />
&nbsp;&nbsp;
<input class="submit_off" type="submit" value="Yes" name="yes" onmouseover="className='submit_on'" onmouseout="className='submit_off'" />
</FORM>
</BODY>

<?php

  include "$footer";

  }

?>